package org.springframework.designPattern.singletonPattern.implb;

public class ToolBox {
    private static volatile ToolBox instance;
    private static final Object lock = new Object();
    private ToolBox() {}

    public static ToolBox getInstance() {
        if (instance == null) {
            instance = new ToolBox();
        }
        return instance;
    }

    public static ToolBox getInstanceSync() {
        if (instance == null) {
            synchronized (lock) {
                if (instance == null) {
                    instance = new ToolBox();
                }
            }
        }
        return instance;
    }
}
